package com.foreverwin.jzymes.production.dismantle.controller;

import com.foreverwin.jzymes.common.util.CarrierUtil;
import com.foreverwin.jzymes.common.util.CommonMethods;
import com.foreverwin.jzymes.framework.base.AjaxResult;
import com.foreverwin.jzymes.framework.exception.BusinessException;
import com.foreverwin.jzymes.production.dismantle.service.IDismantleAlarmDisposeAdviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/production/dismantle")
public class DismantleAlarmDisposeController {

    @Autowired
    IDismantleAlarmDisposeAdviceService dismantleAlarmDisposeAdviceService;

    @RequestMapping("/disposeInspectAlarm")
    public AjaxResult disposeInspectAlarm(@RequestBody Map<String,Object> jsonMap ){
        jsonMap.put( "site", CommonMethods.getSite() );
        try{
            jsonMap.put( "carrier", CarrierUtil.buildCarrier( (String)jsonMap.get( "site" ), (String)jsonMap.get( "carrier" ) ) );
            dismantleAlarmDisposeAdviceService.disposeDismantleAlarm( jsonMap );
            return AjaxResult.returnSuccess();
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }

}
